<template>
  <tr>
    <td><input type="checkbox" v-model="arr.checked" /></td>
    <td>{{ arr.name }}</td>
    <td>{{ arr.price }}</td>
    <td>
      <button @click="red">-</button>
      <span>{{ arr.num }}</span>
      <button @click="add">+</button>
    </td>
    <td>{{ arr.num * arr.price }}</td>
    <td><button @click="del(index)">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: ["arr", "index"],
  methods: {
    red() {
      this.arr.num == 0 ? 0 : this.arr.num--;
    },
    add() {
      this.arr.num++;
    },
    del(index) {
      this.$emit("del", index);
    },
  },
};
</script>

<style>
</style>